{include file='common/head.html'}

<div class="layui-body">
	<div class="layui-tab layui-tab-brief" lay-filter="tab">
	  <ul class="layui-tab-title">
	    <li class="layui-this" lay-id="t1">域名授权</li>
	  </ul>
	  <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">
                <form action="{url./admin/Config/index}" method="post" class="layui-form">
                    <input type="hidden" name="formcheck" value="{$formcheck}">
                    <div class="layui-form-item">
                        <label class="layui-form-label">操作提示</label>
                        <div class="layui-input-block">
                            <blockquote class="layui-elem-quote">授权域名输入框中输入本站需要获取授权码的域名，每行一个！例如：www.baidu.com</blockquote>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">授权域名</label>
                        <div class="layui-input-inline">
                            <textarea name="sn_domain" id="sn_domain" placeholder="请输入本站需要获取授权码的域名，每行一个！例如：www.baidu.com" class="layui-textarea">{$configs.sn_domain.value}</textarea>
                        </div> 
                        <div class="layui-word-aux"><a href="javascript:;" id="getLicense" class="layui-btn layui-btn-primary">获取授权码</a></div>
                        <br>
                        <span class="layui-icon layui-icon-about tips" data-content="请输入本站需要获取授权码的域名，每行一个！例如：www.baidu.com"></span>
                    </div>
                    
                    <div class="layui-form-item">
                        <label class="layui-form-label">系统授权码</label>
                        <div class="layui-input-inline">
                            <input type="text" name="sn" value="{$configs.sn.value}" placeholder="点击上访获取授权码或直接输入手动获取到的授权码"  class="layui-input">
                        </div>
                        <!-- <div class="layui-word-aux"><a href="javascript:;" id="getLicense" class="layui-btn layui-btn-primary">一键授权</a></div> -->
                    </div>

                    {if(session('ucode')==10001)}
                    <div class="layui-form-item">
                        <label class="layui-form-label">授权码手机</label>
                        <div class="layui-input-inline">
                            <input type="text" name="sn_user"  value="{$configs.sn_user.value}" placeholder="请购买了万能授权码的用户填写"  class="layui-input">
                        </div>
                    </div>
                    {/if}
                    
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button class="layui-btn" lay-submit name="submit" value="basic">立即提交</button>
                            <!-- <button type="reset" class="layui-btn layui-btn-primary">重置</button> -->
                        </div>
                    </div>
                </form>
            </div>
	  </div>
	</div>
</div>
<script>
	$(function(){
		$(document).on('click','#getLicense',function(){
			var sn = $('input[name=sn]').val();
			var sn_domain = $("#sn_domain").val();
			var formcheck = $('input[name=formcheck]').val();
			if(sn!==''){
				layer.confirm('已存在授权码，确认需要重新获取么？', {icon: 3, title:'一键授权'}, function(index){
					var load = layer.load(2);
					$.post('{php}echo $_SERVER['PHP_SELF'];{/php}?p=/License/getLicenseAll',
				    {
				        sn_domain:sn_domain,
				        formcheck:formcheck
				    },
				    function(res){
				    	console.log(res);
				        layer.close(load);
				        if(res.code){
				        	layer.msg('获取授权码成功！');
				        	var sn = $('input[name=sn]').val(res.data);
				        	layer.close(index);
				        }else{
				        	layer.alert(res.data);
				        }
				    },'json');
				});
			}
		})
	})
</script>
{include file='common/foot.html'}
